<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

    <script>

        // 解构赋值就是从目标对象或数组中提取自己想要的变量。最常用的场景是：
        // element-ui，vant-ui按需引入，请求接口返回数据,提取想要数据；

        var a,b,rest;
        [a,b] = [10,20]
        console.log(a);
        console.log(b);


        [a,b,...rest] = [10,20,30,40,50];
        console.log(a);
        console.log(b);
        console.log(rest);

        ({a,b, ...rest}={a:10,b:20,c:30,d:40});
        console.log(a);
        console.log(b);
        console.log(rest);

        function f(){
            return [1,2];
        }
        var a,b;
        [a,b]=f();
        console.log(a);
        console.log(b);
    </script>
</body>

</html>